package com.yunfei.core.utils;

import java.sql.*;

public class DbUtilCrmTest {
    public final static String url = "jdbc:oracle:thin:@10.0.100.230:1521:orcl";
    public final static String driverName = "oracle.jdbc.driver.OracleDriver";
    public final static String username = "testkfcrm";
    public final static  String password = "testkfcrm";
    static Connection conn=null;
    public static Connection getConnection(String url, String driverName,String jdbcUserName,String jdbcPassword) {
        try {
            PreparedStatement pstmtTEMP = null;
            ResultSet rs = null;
            Class.forName(driverName);
            conn = DriverManager.getConnection(url, jdbcUserName, jdbcPassword);
        } catch (ClassNotFoundException e) {
            System.out.println("数据库连接错误....");
            e.printStackTrace();
        } catch (SQLException e) {
            System.out.println("数据库连接错误....");
            e.printStackTrace();
        }
        return conn;
    }
    public static void close(PreparedStatement pstmt){
        if(pstmt !=null){
            try {
                pstmt.close();
            } catch (SQLException e) {
                System.out.println("数据库关闭错误....");
                e.printStackTrace();
            }
        }
    }

    public static void close(ResultSet rs){
        if(rs !=null){
            try {
                rs.close();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                System.out.println("结果集关闭错误....");
                e.printStackTrace();
            }
        }
    }
    public static void closeTheConn(){
        if(conn!=null){
            try {
                conn.close();
            } catch (SQLException e) {
                System.out.println("数据库关闭错误....");
                e.printStackTrace();
            }
        }
    }
}
